package org.com.coolfish.scheduler;


import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.TemporalAdjusters;
import java.util.Date;

public class TimeService {

	/*public static String nextMonthLastDay() {
 		
 		LocalDate nextMonth = LocalDate.now().plusMonths(1);
 		LocalDate endDayNextMonth = nextMonth.with(TemporalAdjusters.lastDayOfMonth());
 	
 		return endDayNextMonth.toString();
 	}
	*/
	
	
	public static String monthLastDayLastTime() {
		LocalDate nextMonth = LocalDate.now().plusMonths(0);
 		LocalDate endDayWithMonth = nextMonth.with(TemporalAdjusters.lastDayOfMonth());
		ZoneId zoneId = ZoneId.systemDefault();
        LocalDateTime localDateTime = endDayWithMonth.atTime(23, 59, 59);
        ZonedDateTime zdt = localDateTime.atZone(zoneId);
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = Date.from(zdt.toInstant());
		return sdf.format(date);
	}
	public static String monthLastDayFistTime() {
		LocalDate nextMonth = LocalDate.now().plusMonths(0);
 		LocalDate endDayWithMonth = nextMonth.with(TemporalAdjusters.lastDayOfMonth());
		ZoneId zoneId = ZoneId.systemDefault();
        LocalDateTime localDateTime = endDayWithMonth.atTime(23, 59, 59);
        ZonedDateTime zdt = localDateTime.atZone(zoneId);
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = Date.from(zdt.toInstant());
		return sdf.format(date);
	}
	
	public static String nextMonthFirstDay() {
		LocalDate nextMonth = LocalDate.now().plusMonths(1);
 		LocalDate endDayWithMonth = nextMonth.with(TemporalAdjusters.firstDayOfMonth());
		ZoneId zoneId = ZoneId.systemDefault();
        LocalDateTime localDateTime = endDayWithMonth.atTime(0, 0, 0);
        ZonedDateTime zdt = localDateTime.atZone(zoneId);
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = Date.from(zdt.toInstant());
		return sdf.format(date);
	}
	
	public static String nextMonthLastDay() {
 		
		LocalDate nextMonth = LocalDate.now().plusMonths(1);
 		LocalDate endDayWithMonth = nextMonth.with(TemporalAdjusters.lastDayOfMonth());
		ZoneId zoneId = ZoneId.systemDefault();
        LocalDateTime localDateTime = endDayWithMonth.atTime(23, 59, 59);
        ZonedDateTime zdt = localDateTime.atZone(zoneId);
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date date = Date.from(zdt.toInstant());
		return sdf.format(date);
 	}
	
}
